package com.zy.controller;

import com.zy.entity.Shop;
import com.zy.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

@Controller
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    @GetMapping("/list")
    @ResponseBody
    public List<Shop> listShops() {

        List<Shop> shops = shopService.getAllShops();
        System.out.println(shops);
        for (Shop shop : shops){
            System.out.println(shop.getName());
            System.out.println(shop.getPrice());
            System.out.println(shop.getUrl());
        }
        return shops;
    }
}
